<?php

namespace App\models\forum;

use DB;
use Illuminate\Database\Eloquent\Model;

/**
 * App\models\forum\ReplieVote
 *
 * @property int $uid
 * @property int $replie_id
 * @property \Carbon\Carbon $created_at
 * @property \Carbon\Carbon $updated_at
 * @method static \Illuminate\Database\Query\Builder|\App\models\forum\ReplieVote whereId($value)
 * @method static \Illuminate\Database\Query\Builder|\App\models\forum\ReplieVote whereUid($value)
 * @method static \Illuminate\Database\Query\Builder|\App\models\forum\ReplieVote whereReplieId($value)
 * @method static \Illuminate\Database\Query\Builder|\App\models\forum\ReplieVote whereCreatedAt($value)
 * @method static \Illuminate\Database\Query\Builder|\App\models\forum\ReplieVote whereUpdatedAt($value)
 * @mixin \Eloquent
 * @property int $topic_id
 * @method static \Illuminate\Database\Query\Builder|\App\models\forum\ReplieVote whereTopicId($value)
 */
class ReplieVote extends Model
{
    /**
     * @param int $topic_id
     * @return array
     */
    public static function findReplysVotes($topic_id){
        $temps = self::where('topic_id', $topic_id)->get();
        $arr    = array();
        foreach ($temps as $temp){
            $arr[$temp->replie_id] = $topic_id;
        }
        return $arr;
    }

    public function deleteMe(){
        return DB::delete('delete FROM replie_votes where uid = ? and replie_id = ?', [$this->uid, $this->replie_id]);
    }
}
